﻿@using System.Web.Mvc.Html
@model GameSchool.ViewModels.Video.ListViewModel
@{
    ViewBag.Title = "Listi yfir myndbönd";
    

}
@if (User.IsInRole("Kennari"))
{
    <h2>
        Skrá/breyta myndbandi í @Model.currentCourse.Code, @Model.currentCourse.Name, @Model.currentCourse.Semester.Year-@Model.currentCourse.Semester.SemesterOfYear</h2>
        
    <p>
        <a href="@Url.Action("Create", new { id = Model.currentCourseId })" class="btn">Skrá
            nýtt myndband</a>
    </p>
}
else
{
    <h2>
        Myndbandalisti fyrir @Model.currentCourse.Code, @Model.currentCourse.Name, @Model.currentCourse.Semester.Year-@Model.currentCourse.Semester.SemesterOfYear</h2>
}
<table class="table table-striped">
    <tr>
        <th>
            Heiti
        </th>
        <th>
            Röðun
        </th>
        <th>
            Lýsing
        </th>
        @if (User.IsInRole("Nemandi"))
        {
            <th>
                <span>Búið að horfa á</span>
            </th>
        }
        <th>
        </th>
    </tr>
    @if (User.IsInRole("Kennari"))
    {
        var countNum = 1;
        foreach (var item in Model.videoList.OrderBy(x => x.VideoID))
        {
        <tr>
            <td>
                @Html.ActionLink(item.Name, "Watch", new { id = item.VideoID })
            </td>
            <td>
                @countNum
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Description)
            </td>
            <td>
                @Html.ActionLink("Breyta", "Edit", new { id = item.VideoID }, new { @class = "btn btn-mini" })
                @Html.ActionLink("Horfa", "Watch", new { id = item.VideoID }, new { @class = "btn btn-mini" })
            </td>
        </tr>
            countNum++;
        }
    }
    @if (User.IsInRole("Nemandi"))
    {
        var ordered = Model.videoList.OrderBy(x => x.VideoID);
        var countNum = 1;
        foreach (var item in ordered)
        {
        <tr>
            <td>
                @Html.ActionLink(item.Name, "Watch", new { id = item.VideoID })
            </td>
            <td>
                @countNum
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Description)
            </td>
            <td>
                <label class="checkbox1">
                    <input type="checkbox" />
                </label>
            </td>
            <td>
                @Html.ActionLink("Horfa", "Watch", new { id = item.VideoID }, new { @class = "btn btn-mini" })
            </td>
        </tr>
            countNum++;
        }
    }
</table>
